<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/25
 * Time: 16:00
 */

namespace App\Model;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Goods extends Model
{
    protected $table = 'nb_goods';


    /**
     * 商品列表
     * @author: cyc<gan_fei_ni@126.com>
     * @copyright:
     * @param array|string $cond 筛选条件
     * @param $page
     * @param $page_size
     * @param $order
     * @return \Illuminate\Support\Collection
     */
    public function listByPage($cond,$page,$page_size,$order){
        return $this->whereRaw($cond)->forPage($page,$page_size)->orderByRaw($order)->get();
    }

    /**
     *
     * @author: cyc<gan_fei_ni@126.com>
     * @copyright:
     * @param $cond
     * @return int
     */
    public function countGoods($cond){
        return $this->whereRaw($cond)->count();
    }
}